<?php
/* @var $this ChannelController */
/* @var $model Channel */

$this->pageTitle = '栏目';
$this->breadcrumbs = array(
	'栏目',
);
?>

	<div class="page-header">
		<h1>栏目 <?php echo CHtml::link('创建', array('create'), array('class' => 'btn btn-link')); ?></h1>
	</div>

	<p>
		<?php /* @var $form TbActiveForm */
		if ($view == 'trash') {
			$actions = array(
				'' => '批量操作',
				'reset' => '还原',
			);
			echo CHtml::link('&lt;&lt;返回', array('index'));
		} else {
			$actions = array(
				'' => '批量操作',
				'trash' => '移动至回收站',
			);
			echo CHtml::link('<i class="fa fa-trash-o"></i> 回收站', array('index', 'view' => 'trash'));
		}
		?>
	</p>
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'type' => 'horizontal',
));
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
	'id' => 'channel-grid',
	'dataProvider' => new CArrayDataProvider($model->getTree(), array(
			'pagination' => array(
				'pageSize' => 50,
			),
		)),
	'bulkActions' => array(
		'class' => 'YBulkActions',
		'align' => 'left',
		'actionButtons' => $actions,
	),
	//'rowHtmlOptionsExpression' => 'array("class"=>"level-" .$data->depth)',
	'columns' => array(
		array(
			'name' => 'id',
			'class' => 'CCheckBoxColumn',
			'checkBoxHtmlOptions' => array('name' => 'ids[]'),
			'selectableRows' => 2,
			'disabled' => '$data->isSystemChannel()',
		),
		/*
		array(
			'name' => 'id',
			'header' => $model->getAttributeLabel('id'),
			'headerHtmlOptions' => array('class' => 'id-column'),
		),
		*/
		array(
			'name' => 'title',
			'type' => 'raw',
			'header' => $model->getAttributeLabel('title'),
			'value' => '"<span class=\"depth-indent\">" . str_repeat(" — ", $data->depth) . "</span>" . $data->title',
			'htmlOptions' => array('class' => 'title-column'),
		),
		array(
			'name' => 'name',
			'header' => $model->getAttributeLabel('name'),
		),
		array(
			'name' => 'type',
			'header' => $model->getAttributeLabel('type'),
			'value' => '$data->typeList[$data->type]',
		),
		array(
			'class' => 'YInputColumn',
			'name' => 'weight',
			'header' => $model->getAttributeLabel('weight'),
			'inputHtmlOptions' => array('name' => 'weight')
		),
		array(
			'header' => '操作',
			'type' => 'raw',
			'value' => '$data->getContentActionLink()',
		),
		array(
			'class' => 'bootstrap.widgets.TbButtonColumn',
			'deleteConfirmation' => '删除这个栏目将会导致该栏目下的所有内容将被删除！请谨慎操作！',
			'template' => '{view} {update} {delete}',
			'buttons' => array(
				'trash' => array(
					'label' => '移动至回收站',
					'url' => 'Yii::app()->controller->createUrl("trash", array("id"=>$data->id))',
					'icon' => 'trash',
					'visible' => '$data->status == Channel::STATUS_DEFAULT',
				),
				'delete' => array(
					'label' => '彻底删除',
					'visible' => '$data->status == Channel::STATUS_TRASH && !$data->isSystemChannel()',
				),
			),
		),
	),
)); ?>
	<div class="text-right">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType' => 'submit',
			'htmlOptions' => array('name' => 'saveWeight'),
			'type' => 'secondary',
			'label' => '保存权重',
		));
		?>
	</div>
<?php $this->endWidget(); ?>